from langchain_community.llms.tongyi import Tongyi
from langchain_core.prompts.prompt import PromptTemplate
from langchain.chains import LLMChain

import os

os.environ["DASHSCOPE_API_KEY"] = "sk-9d8f1914800e497f8717144e860f99bc"
# 调用模型
llm = Tongyi()
# 提示词
prompt = PromptTemplate(
    input_variables=["content1", 'content2'],
    template="关于{content1}{content2}是什么?请中文回复我"
)
# 构建链
chain = LLMChain(llm=llm, prompt=prompt)
# 提问
res = chain.invoke({'content1': '苹果', 'content2': '笑话'})
print(res)
